package com.ipc.admin.controller.gwl;


import com.ipc.admin.service.gwl.service.SecondScreenDetailService;
import com.ipc.common.pojo.bo.gwl.PageAndSearchBo;
import com.ipc.common.pojo.vo.R;
import com.ipc.common.util.gwl.NullJudgeUtil;
import com.ipc.core.entity.gwl.SecondScreenDetail;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 三级诱导屏详情(SecondScreenDetail)表控制层
 *
 * @author 高万里
 * @since 2023-05-02 11:31:19
 */
@CrossOrigin
@RestController
@RequestMapping("/api/secondScreenDetail/")
@Api(tags = "三级诱导屏详情")
public class SecondScreenDetailController {
    /**
     * 服务对象
     */
    @Resource
    private SecondScreenDetailService service;
    
    /**
     * 新增数据
     *
     * @param secondScreenDetail 实体对象
     * @return 新增结果
     */
    @PostMapping("add")
    @ApiOperation(value = "",notes = "要求所有信息不能为空")
    public R add(@RequestBody @Valid SecondScreenDetail secondScreenDetail, BindingResult result) {
        String info = NullJudgeUtil.nullJudge(result);
        if (info != null) {
            return R.fail(info);
        }
        return service.add(secondScreenDetail);
    }
    
    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @ApiOperation(value = "根据list集合删除数据")
    @PostMapping("delete")
    public R delete(@RequestParam("idList") List<Long> idList) {
        return service.del(idList);
    }
    
    /**
     * 修改数据
     *
     * @param secondScreenDetail 实体对象
     * @return 修改结果
     */
    @ApiOperation(value = "修改数据")
    @PostMapping("update")
    public R update(@RequestBody SecondScreenDetail secondScreenDetail, BindingResult result) {
    String info = NullJudgeUtil.nullJudge(result);
        if (info != null) {
            return R.fail(info);
        }
        return service.update(secondScreenDetail);
    }

    /**
     * 分页查询所有数据
     *
     * @param bo 分页对象
     * @return 所有数据
     */
    @ApiOperation(value = "分页查询所有数据")
    @GetMapping("selectAll")
    public R selectAll(PageAndSearchBo bo) {
        return service.selectAll(bo);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation(value = "通过主键查询单条数据")
    @GetMapping("{id}")
    public R selectOne(@PathVariable int id) {
        return service.selectOne(id);
    }

    /**
     * 查询所有停车场ID和名称
     *
     * @return 单条数据
     */
    @ApiOperation(value = "查询所有停车场ID和名称")
    @GetMapping("selectAllPark")
    public R selectAllPark(int id) {
        return service.selectAllPark(id);
    }
}

